package com.stm.bi.web;

import com.stm.bi.dto.query.DemoChartQuery;
import com.stm.bi.dto.vo.DemoStatisticsVO;
import com.stm.bi.model.Chart;
import com.stm.bi.model.DatatablePage;
import com.stm.bi.model.DatatableQuery;
import com.stm.bi.service.DemoService;
import com.stm.framework.annotation.Module;
import com.stm.framework.annotation.RestApi;
import com.stm.framework.dto.Response;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
*
*
* @author chenyingjun
* @date 2025-01-11
*/
@RestController
@RequestMapping("/demo")
@Module("演示报表")
public class DemoController {
    @Resource
    private DemoService demoService;

    @GetMapping(value = "/chart")
    @RestApi(name = "图表查询",author = "阿俊",idx=1)
    public Response<Chart<DemoStatisticsVO>> queryChart(DemoChartQuery demoChartQuery){
        return demoService.queryChart(demoChartQuery);
    }

    @GetMapping(value = "/datatable")
    @RestApi(name = "二维表查询",author = "阿俊",idx=2)
    public Response<DatatablePage<DemoStatisticsVO>> queryDatatable(DatatableQuery datatableQuery){
        return demoService.queryDatatable(datatableQuery);
    }

    @GetMapping(value = "/datatable/exp")
    @RestApi(name = "二维表导出",author = "阿俊",idx=3)
    public void expDatatable(HttpServletResponse servletResponse,DatatableQuery datatableQuery) throws IOException {
        demoService.expDatatable(servletResponse,datatableQuery);
    }

}
